package cn.demoncat.util.lang.entity.data;

import java.util.Objects;

/**
 * 键值对条目：Map.Entry
 * 
 * @author 延晓磊
 *
 * @since 2020年7月16日
 */
public class MapEntry<K, V> {

	// 键
	private K key;
	// 值
	private V val;

	public MapEntry() {
		super();
	}

	public MapEntry(K key) {
		super();
		this.key = key;
	}

	public MapEntry(K key, V val) {
		super();
		this.key = key;
		this.val = val;
	}

	public K getKey() {
		return key;
	}

	public void setKey(K key) {
		this.key = key;
	}

	public V getVal() {
		return val;
	}

	public void setVal(V val) {
		this.val = val;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		MapEntry<?, ?> mapEntry = (MapEntry<?, ?>) o;
		return Objects.equals(key, mapEntry.key) &&
				Objects.equals(val, mapEntry.val);
	}

	@Override
	public int hashCode() {
		return Objects.hash(key, val);
	}

	@Override
	public String toString() {
		return key + "=" + val;
	}
	
}
